package com.udf.flink.scala

import org.apache.flink.api.common.functions.AggregateFunction
import org.apache.flink.api.scala._
import org.apache.flink.streaming.api.scala._
import org.apache.flink.table.api.TableEnvironment
//import org.apache.flink.table.api.scala._

/**
 * Description: No Description
 *
 * @author tieyi  2019/12/11 15:10
 * @version 1.0.0
 */
object MyUDAF {
  def main(args: Array[String]): Unit = {
    val senv = StreamExecutionEnvironment.getExecutionEnvironment
    //senv.re
    //val env = ExecutionEnvironment.getExecutionEnvironment
//    val tEnv = BatchTableEnvironment.create(env)
    //val tEnv = TableEnvironment.create(env)
  }
}
case class user(name:String,age:Long)
class sumAgeAggUDAF extends AggregateFunction[user,Long,Long]{
  override def createAccumulator(): Long = 0L

  override def add(in: user, acc: Long): Long = acc + in.age

  override def getResult(acc: Long): Long = acc

  override def merge(acc: Long, acc1: Long): Long = acc + acc1
}
